package com.neiquan.backstage.event.imp;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.neiquan.backstage.common.util.ExtraSpringHibernateTemplate;
import com.neiquan.backstage.event.EventProposerService;
import com.neiquan.backstage.pub.bsc.dao.po.EventProposer;

@Service
public class EventProposerServiceImp implements EventProposerService {
	private static Class<?> poc = EventProposer.class;
	@Autowired
	private ExtraSpringHibernateTemplate extraSpringHibernateTemplate;

	@Override
	public void add(EventProposer entity) {
		// TODO Auto-generated method stub
		extraSpringHibernateTemplate.getHibernateTemplate().save(entity);
	}

	@Override
	public EventProposer queryById(int id) {
		// TODO Auto-generated method stub
		return extraSpringHibernateTemplate.findFirstOneByPropEq(poc, "proposerId", id);
	}

	@Override
	public void updata(EventProposer entity) {
		// TODO Auto-generated method stub
		extraSpringHibernateTemplate.getHibernateTemplate().update(entity);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<EventProposer> queryAll() {
		// TODO Auto-generated method stub
		return (List<EventProposer>) extraSpringHibernateTemplate.findAll(poc);
	}

	@Override
	public List<EventProposer> queryByMemberId(Integer memberId) {
		// TODO Auto-generated method stub
		return (List<EventProposer>) extraSpringHibernateTemplate.getHibernateTemplate().find("From EventProposer where memberId=?", memberId);
	}

}
